﻿<Window x:Class="Effector.Dialogs.NewEffectFileDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:localModel="clr-namespace:Effector.ViewModel"
    Title="New Effect File" Height="400" Width="400" HorizontalContentAlignment="Stretch" 
        VerticalContentAlignment="Stretch" x:Name="newEffectFileDialog" MaxWidth="400" MaxHeight="400" 
        MinWidth="400" MinHeight="400" ResizeMode="NoResize">
	<Window.Background>
		<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
			<GradientStop Color="#FF5658E7" Offset="0"/>
			<GradientStop Color="#FF181958" Offset="1"/>
		</LinearGradientBrush>
	</Window.Background>
    <Grid>
        <Grid.Resources>

            <!--ItemTemplate for the logical drive model to display the name property-->
            <HierarchicalDataTemplate DataType="{x:Type localModel:LogicalDriveModel}" 
                                      ItemsSource="{Binding Children}">
                <TextBlock Text="{Binding DriveName}"/>
            </HierarchicalDataTemplate>
            
        </Grid.Resources>
        <Button HorizontalAlignment="Right" Margin="0,0,111,19" VerticalAlignment="Bottom" Width="76" Height="22" Background="#FF6F79C7" Content="Ok" x:Name="okButton" IsDefault="True" Click="OkButton_Clicked" />
    	<Button Margin="0,0,8,19" VerticalAlignment="Bottom" Height="22" Content="Cancel" Background="#FF7E88D9" x:Name="canselButton" IsCancel="True" HorizontalAlignment="Right" Width="85" />
        <TextBox Margin="135,0,8,54" VerticalAlignment="Bottom" Height="23" TextWrapping="Wrap" x:Name="fileExtensionTextBox" Text=".fx" IsReadOnly="True">
        </TextBox>
        <TextBox Margin="135,0,8,90" VerticalAlignment="Bottom" Height="23" TextWrapping="Wrap" RenderTransformOrigin="0.5,0.5" VerticalScrollBarVisibility="Disabled" x:Name="fileNameTextBox" TextChanged="OnFileNameTextBoxTextChanged">
        </TextBox>
    	<Label Margin="8,0,0,54" VerticalAlignment="Bottom" Height="23" Content="File Extension" HorizontalAlignment="Left" Width="121" />
    	<Label Margin="8,0,0,90" VerticalAlignment="Bottom" Height="23" Content="Filename" HorizontalAlignment="Left" Width="121" />
        <TreeView Margin="8,28.886,8,117" x:Name="directoryPathTreeView" FontStretch="Condensed" 
                  Grid.ColumnSpan="2" ItemsSource="{Binding LogicalDrives}" SelectedItemChanged="OnTreeViewSelectionChanged">
            
            <!--Bind the IsExpanded and IsSelected properties of the treeviewitem to the 
                ones in the binded object in two way.Whichever is changing the other does
                too.-->
            <TreeView.ItemContainerStyle>
                <Style TargetType="{x:Type TreeViewItem}">
                    <Setter Property="ItemsSource" Value="{Binding Children}"/>
                    <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
                </Style>
            </TreeView.ItemContainerStyle>
            
            <TreeView.Resources>
                
                <!--how to display the LogicalDriveModel in the tree view, 
                    items source is taken from the treeviewitem style-->
                <HierarchicalDataTemplate DataType="{x:Type localModel:LogicalDriveModel}" >
                    <StackPanel Orientation="Horizontal">
                        <Image Width="16" Height="16" Source="/Dialogs/Images/harddisc.png"/>
                        <TextBlock Text="{Binding DriveName}"/>
                    </StackPanel>
                </HierarchicalDataTemplate>
                
                <!--how to display the DirectoryModel in the tree view , 
                    items source is taken from the treeviewitem style-->
                <HierarchicalDataTemplate DataType="{x:Type localModel:DirectoryModel}" >
                    <StackPanel Orientation="Horizontal">
                        <Image Width="16" Height="16" Source="/Dialogs/Images/Folder.png"/>
                        <TextBlock Text="{Binding DirectoryName}"/>
                    </StackPanel>
                </HierarchicalDataTemplate>
            </TreeView.Resources>
        </TreeView>
            <ComboBox Height="20" Margin="158,3.333,12,0" Name="drivesComboBox" 
                  VerticalAlignment="Top" ItemsSource="{Binding LogicalDrives}" SelectionChanged="OnComboBoxSelectionChanged">
        </ComboBox>
        <Label Height="20" Margin="8,3.333,0,0" Name="label1" VerticalAlignment="Top" Padding="5,2,5,2" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" HorizontalAlignment="Left" Width="144">Drives</Label>
    </Grid>
</Window>
